﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ChurchData.Business;

namespace ChurchData
{
    public partial class PeopleSecureNotesUC : UserControl
    {
        #region Fields/Properties
        private int PeoplePK { get; set; }
        public bool HasUnsavedChanges { get; set; }

        #endregion Fields/Properties

        #region Constructor
        public PeopleSecureNotesUC()
        {
            InitializeComponent();
        }

        #endregion Constructor

        #region Populate Methods
        public void LoadPersonInfo(int peoplePK)
        {
            this.PeoplePK = peoplePK;

            People person = new PeopleBO().GetRecordByPK(this.PeoplePK);
            this.txtSecureNotes.Text = person.SecureNotes;

            if (UserInformation.ViewOnlyInd)
            {
                this.txtSecureNotes.Enabled = false;
                this.txtSecureNotes.BackColor = Color.White;
            }

            this.HasUnsavedChanges = false;
        }

        #endregion Populate Methods

        #region Save Methods
        public void SaveIt()
        {
            PeopleBO pBO = new PeopleBO();
            pBO.UpdateSecureNotes(this.PeoplePK, txtSecureNotes.Text.Trim());
            this.HasUnsavedChanges = false;
        }

        #endregion Save Methods

        #region Control Events
        private void txtSecureNotes_TextChanged(object sender, EventArgs e)
        {
            this.HasUnsavedChanges = true;
        }

        #endregion Control Events
    }
}
